/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.manageBean;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Unix
 */
@ManagedBean
@RequestScoped
public class LoginBean {  
  
    private String username;  
      
    private String password;  
      
    public String getUsername() {  
        return username;  
    }  
  
    public void setUsername(String username) {  
        this.username = username;  
    }  
  
    public String getPassword() {  
        return password;  
    }  
  
    public void setPassword(String password) {  
        this.password = password;  
    }  
  
    public void login(ActionEvent actionEvent) {  
        
        FacesMessage msg = null;
        
         if(username != null  && username.equals("admin") && password != null  && password.equals("admin"))
        {  
            try {
                FacesContext.getCurrentInstance().getExternalContext().redirect("faces/Sistema.xhtml");
            } catch (IOException ex) {
                Logger.getLogger(LoginBean.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
             msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,"Item Selected","111111111111");               
        }
         FacesContext.getCurrentInstance().addMessage(null,msg);         
    }  
}  
